<template>
	<div class="collect">
		<!-- Add a static page for my favorite module -->
		<div class="collect-header">
			<div class="collect-title">
				<i class="el-icon-collection-tag" style="color: #ff6700;"></i>
				我的收藏
			</div>
		</div>

		<!-- 收藏主题内容	 -->
		<div class="main-box">
			<div class="main">
				<el-row>
					<el-col :span="5" v-for="(item, index) in productStaticList" :key="index">
						<el-card :body-style="{ padding: '0px' }">
							<img class="image" :src="item.productImage" alt/>
							<div style="padding-bottom: 50px; height:10px" >
								<span>{{item.productName}}</span>
								<div class="bottom clearfix">
									<time class="time">{{item.price}} 元</time>
									<el-button type="text" class="button" @click="removeCollection(item.productId)">取消收藏</el-button>
								</div>
							</div>
						</el-card>
					</el-col>
				</el-row>
			</div>
		</div>
		<!-- 收藏主题内容END -->
	</div>
</template>

<script>
	import collectApi from '../api/collect.js'

	export default {
		name: "Collect",
		data() {
			return {
				// currentDate: new Date(),
				productStaticList: [],
			}
		},
		activated() {
			this.listCollection()
		},
		methods: {
			//查询所有的收藏
			listCollection() {
				const memberId = this.$store.getters.getUser.userId
				collectApi.listCollection(memberId)
					.then(res => {
						this.productStaticList = res.data
					})

			},
			//移除收藏
			removeCollection(productId) {
				const memberId = this.$store.getters.getUser.userId
				collectApi.removeCollection(memberId, productId)
					.then(res => {
						this.notifySucceed(res.msg)
						this.listCollection()
					})
			}

		},
	}
</script>

<style scoped>
	/* home拿过来的样式 */
	@import "../assets/css/index.css";

	/* 卡片样式 */
	.time {
		font-size: 13px;
		color: #999;
	}

	.bottom {
		line-height: 12px;
	}

	.button {
		padding: 0;
		float: right;
	}

	.image {
		width: 100%;
		display: block;
	}

	.clearfix:before,
	.clearfix:after {
		display: table;
		content: "";
	}

	.clearfix:after {
		clear: both
	}

	.myList ul li {
		z-index: 1;
		float: left;
		width: 234px;
		height: 280px;
		padding: 10px 0;
		margin: 0 0 14.5px 13.7px;
		background-color: white;
		-webkit-transition: all 0.2s linear;
		transition: all 0.2s linear;
		position: relative;
	}

	.myList ul li:hover {
		z-index: 2;
		-webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
		box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
		-webkit-transform: translate3d(0, -2px, 0);
		transform: translate3d(0, -2px, 0);
	}

	.myList ul li img {
		display: block;
		width: 160px;
		height: 160px;
		background: url(../assets/imgs/placeholder.png) no-repeat 50%;
		margin: 0 auto;
	}

	.myList ul li h2 {
		margin: 25px 10px 0;
		font-size: 14px;
		font-weight: 400;
		color: #333;
		text-align: center;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.myList ul li h3 {
		margin: 5px 10px;
		height: 18px;
		font-size: 12px;
		font-weight: 400;
		color: #b0b0b0;
		text-align: center;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.myList ul li p {
		margin: 10px 10px 10px;
		text-align: center;
		color: #ff6700;
	}

	.myList ul li p .del {
		margin-left: 0.5em;
		color: #b0b0b0;
		text-decoration: line-through;
	}

	.myList #more {
		text-align: center;
		line-height: 280px;
	}

	.myList #more a {
		font-size: 18px;
		color: #333;
	}

	.myList #more a:hover {
		color: #ff6700;
	}

	.myList ul li .delete {
		position: absolute;
		top: 10px;
		right: 10px;
		display: none;
	}

	.myList ul li:hover .delete {
		display: block
	}

	.myList ul li .delete:hover {
		color: #ff6700;
	}

	.el-carousel__item h3 {
		color: #475669;
		font-size: 14px;
		opacity: 0.75;
		line-height: 200px;
		margin: 0;
	}

	.el-carousel__item:nth-child(2n) {
		background-color: #99a9bf;
	}

	.el-carousel__item:nth-child(2n+1) {
		background-color: #d3dce6;
	}

	/* //头部栏样式 */
	.collect {
		background-color: #f5f5f5;
	}

	.collect .collect-header {
		height: 64px;
		background-color: #fff;
		border-bottom: 2px solid #ff6700;
	}

	.collect .collect-header .collect-title {
		width: 1225px;
		margin: 0 auto;
		height: 64px;
		line-height: 58px;
		font-size: 28px;
	}

	.collect .content {
		padding: 20px 0;
		width: 1225px;
		margin: 0 auto;
	}

	.collect .content .goods-list {
		margin-left: -13.7px;
		overflow: hidden;
	}

	/* 收藏列表为空的时候显示的内容CSS */
	.collect .collect-empty {
		width: 1225px;
		margin: 0 auto;
	}

	.collect .collect-empty .empty {
		height: 300px;
		padding: 0 0 130px 558px;
		margin: 65px 0 0;
		background: url(/assets/imgs/cart-empty.png) no-repeat 124px 0;
		color: #b0b0b0;
		overflow: hidden;
	}

	.collect .collect-empty .empty h2 {
		margin: 70px 0 15px;
		font-size: 36px;
	}

	.collect .collect-empty .empty p {
		margin: 0 0 20px;
		font-size: 20px;
	}

	/* 收藏列表为空的时候显示的内容CSS END */


</style>
